	<div style="border:0px solid #000; width:950px; margin:auto">
    	<a href="http://www.clinicadesirer.com.br"><img src="<?= base_url(); ?>images/logo.png" style="margin:0 0 0 -120px;" /></a> 
    </div>
    <script type="text/javascript">
		function checkForm(param)
		{
			document.formAgendar.hid_oper.value = param;

			var arr_fields = [
			                  {nome:'hid_oper',label:'', tp_obj: 'hid'},
			                  {nome:'horario',label:'', tp_obj: 'hid'},
			                  {nome:'data_consulta',label:'', tp_obj: 'hid'},
			                  {nome:'dia_semana',label:'', tp_obj: 'hid'},
			                  {nome:'medico',label:'Medico', tp_obj: 'sel'},
			                  {nome:'emailCad',label:'E-mail', tp_obj: 'txt'},
			                  {nome:'nome',label:'Nome', tp_obj: 'txt'},
			                  {nome:'endereco',label:'Endereco', tp_obj: 'txt'},
			                  {nome:'bairro',label:'Bairro', tp_obj: 'txt'},
			                  {nome:'numero',label:'Numero', tp_obj: 'txt'},
			                  {nome:'cidade',label:'Cidade', tp_obj: 'txt'},
			                  {nome:'uf',label:'UF', tp_obj: 'sel'},
			                  {nome:'complemento',label:'Complemento', tp_obj: 'txt'},
			                  {nome:'cep',label:'CEP', tp_obj: 'txt'},
			                  {nome:'email',label:'E-mail', tp_obj: 'txt'},
			                  {nome:'telefone',label:'Telefone', tp_obj: 'txt'},
			                  {nome:'celular',label:'Celular', tp_obj: 'txt'}
				              	];

			var hid_oper = $("#hid_oper"),
			horario = $("#horario"),
			data_consulta = $("#data_consulta"),
			dia_semana = $("#dia_semana"),
			medico = $("#medico"),
			emailCad = $("#emailCad"),
			nome = $("#nome"),
			endereco = $("#endereco"),
			bairro = $("#bairro"),
			numero = $("#numero"),
			cidade = $("#cidade"),
			uf = $("#uf"),
			complemento = $("#complemento"),
			cep = $("#cep"),
			email = $("#email"),
			telefone = $("#telefone"),
			celular = $("#celular"),
			allFields = $([])
						.add(hid_oper)
						.add(horario)
						.add(data_consulta)
						.add(dia_semana)
						.add(medico)
						.add(emailCad)
						.add(nome)
						.add(endereco)
						.add(bairro)
						.add(numero)
						.add(cidade)
						.add(uf)
						.add(complemento)
						.add(cep)
						.add(email)
						.add(telefone)
						.add(celular),
			tips = $(".validateTips");

			var bValid = true;
			allFields.removeClass('ui-state-error');

			if(param == "reg")
			{
				bValid = bValid && validation(emailCad, "E-mail", "required", tips, 0, 0);
				bValid = bValid && validation(emailCad, "E-mail", "email", tips, 0, 0);
			}
			else
			{
				//Required
				bValid = bValid && validation(nome, "Nome", "required", tips, 0, 0);
				bValid = bValid && validation(endereco, "Endereco", "required", tips, 0, 0);
				bValid = bValid && validation(bairro, "Bairro", "required", tips, 0, 0);
				bValid = bValid && validation(numero, "Numero", "required", tips, 0, 0);
				bValid = bValid && validation(cidade, "Cidade", "required", tips, 0, 0);
				bValid = bValid && validation(uf, "UF", "required", tips, 0, 0);
				bValid = bValid && validation(cep, "CEP", "required", tips, 0, 0);
				bValid = bValid && validation(email, "E-mail", "required", tips, 0, 0);

				//Length
				bValid = bValid && validation(nome, "Nome", "length", tips, 3, 150);
				bValid = bValid && validation(endereco, "Endereco", "length", tips, 3, 150);
				bValid = bValid && validation(bairro, "Bairro", "length", tips, 3, 150);
				bValid = bValid && validation(numero, "Numero", "length", tips, 1, 10);
				bValid = bValid && validation(cidade, "Cidade", "length", tips, 3, 150);
				bValid = bValid && validation(uf, "UF", "length", tips, 2, 2);
				bValid = bValid && validation(complemento, "Complemento", "length", tips, 0, 250);
				bValid = bValid && validation(cep, "CEP", "length", tips, 8, 10);
				bValid = bValid && validation(email, "E-mail", "length", tips, 5, 150);
				bValid = bValid && validation(telefone, "Telefone", "length", tips, 0, 15);
				bValid = bValid && validation(celular, "Celular", "length", tips, 0, 15);

				//Email
				bValid = bValid && validation(email, "E-mail", "email", tips, 0, 0);
			}

			if(bValid)
			{
				eval(fc_get_fields(arr_fields));
				$.ajax({
					  type: 'POST',
					  url: '<?php echo base_url()."site/confirmar"?>',
					  data: arr_data,
					  success: function(msg){
					  		var type = msg.substr(0,3);
							var msgs = msg.substr(4);
					  		if(type != "err")
					  		{
								dialogMessage(msgs,'dialog-message');   
					    		fc_reset_form(arr_fields);
								allFields.val('').removeClass('ui-state-error');
					  		}
					  		else
					  		{
					  			dialogMessage(msgs,'dialog-message');
						  	}
						}
				});
			}			
		}
	</script>
	<div id="dialog-message" title="Mensagem" style="display:none;"></div>
    <form action="<?= base_url(); ?>site/confirmar" method="post" id="formAgendar" name="formAgendar">
    	<input type="hidden" name="hid_oper" id="hid_oper" value="" />
    	<input type="hidden" name="horario" id="horario" value="<?= $horario[0]->horario; ?>" />
    	<input type="hidden" name="data_consulta" id="data_consulta" value="<?= $data; ?>" />
    	<input type="hidden" name="dia_semana" id="dia_semana" value="<?= $horario[0]->id_dias_semana_fk; ?>" />
        <div style="border:0px solid #000; width:930px; height:800px; padding:0 10px 10px; margin:40px auto 0; background:url(<?= base_url(); ?>images/bg_rodape.png) #fff repeat-x; background-position:bottom;">
            <?php 
            foreach ($especialidades as $dados) 
            {
            ?>
            <h1 style="padding:20px 0 0 0; color:#063;"><?= utf8_decode($dados->descricao); ?></h1>
            <?php
            }
            ?>
            <p>Selecione o profissional na lista abaixo.</p>
            <ul>
            	<li>
                	<select name="medico" id="medico" style="width:400px; padding:5px;">
                    	<?php 
                    	foreach ($medicos as $dados) 
                    	{
                    	?>
                        <option value="<?= $dados->id; ?>"><?= utf8_decode($dados->nome); ?></option>
                    	<?php
                    	}
                    	?>
                    </select>
                </li>           
               <li>
                	<div style="padding:7px 10px; border:1px solid #f2f2f2; background:#f9f9f9;">
                        <span style="text-align:right"><b><?= utf8_decode($dia_semana[0]->descricao); ?> | <?= substr($horario[0]->horario,0,5); ?> hs |</b> <?= $diaMes; ?>.</span>
                    </div>
            	</li>
            </ul>
			<p class="validateTips">Os campos com * s&atilde;o obrigat&oacute;rios.</p>
            <div id="clear"></div>
            <div id="box_sou_cadastrado">
            	<h2>J&aacute; sou cadastrado</h2>
                <p>Digite seu email para confirmar o agendamento.</p>
                <div id="clear"></div>
                <ul>
                	<li><b>Digite seu E-Mail</b></li><br />
                    <li><input name="emailCad" id="emailCad" type="text" style="padding:5px; width:250px; margin:10px 0 0 0;" /></li>
                    <li><input name="btConfirmarAgendamento" type="button" value="Confirmar Agendamento" onclick="checkForm('reg');" style="background:#063; color:#fff; margin:10px 0 0 0; font-weight:bold; border:none; padding:7px 10px; outline:none; cursor:pointer;"/></li>
                </ul>
            </div>
            <div id="box_cadastro">
            	<h2>N&atilde;o sou cadastrado.</h2>
                <p>Preencha o formul&aacute;rio abaixo para confirmar o agendamento.</p>
                <div id="clear"></div>
                <table border="0">
                	<tr>
                    	<td colspan="3">
                        	<b>Nome</b>
                            <br /><input name="nome" id="nome" type="text" style="padding:5px; width:400px;" />
                        </td>
                    </tr>
                    <tr>
                    	<td colspan="3">
                        	<b>Endere&ccedil;o</b>
                            <br /><input name="endereco" id="endereco" type="text" style="padding:5px; width:400px;" />
                        </td>
                    </tr>
                    <tr>
                     	<td>
                        	<b>Bairro</b>
                            <br /><input name="bairro" id="bairro" type="text" style="padding:5px; width:250px;" />
                        </td>
                        <td width="20"></td>
                    	<td>
                        	<b>N&uacute;mero</b>
                            <br /><input name="numero" id="numero" type="text" style="padding:5px; width:85px;" />
                        </td>
                    </tr>
                    <tr>
                    	<td>
                        	<b>Cidade</b>
                            <br /><input name="cidade" id="cidade" type="text" style="padding:5px; width:250px;" />
                        </td>
                        <td width="20"></td>
                        <td>
                        	<b>UF</b>
                            <br />
                            <select name="uf" id="uf" style="padding:5px; width:100px;" >
							<?php 
								$keys = array_keys($estados);
								for($i=0; $i<count($keys); $i++)
								{
									$flag = FALSE;
									if($keys[$i] == "PE")
									{
										$flag = TRUE;
									}
							?>
								<option value="<?= $keys[$i]; ?>" <?= $flag?"selected":""; ?>><?= $keys[$i]; ?></option>
							<?php 		
								}
							?>
                            </select>
                        </td>
                    </tr>
                    <tr>
                    	<td>
                        	<b>Complemento</b>
                            <br /><input name="complemento" id="complemento" type="text" style="padding:5px; width:250px;" />
                        </td>
                        <td width="20"></td>
                    	<td>
                        	<b>CEP</b>
                            <br /><input name="cep" id="cep" type="text" style="padding:5px; width:85px;" />
                        </td>
                    </tr>
                    <tr>
                    	<td colspan="3">
                        	<b>E-mail</b>
                            <br /><input name="email" id="email" type="text" style="padding:5px; width:400px;" />
                        </td>
                    </tr>
                    <tr>
                    	<td colspan="3">
                        	<b>Tefefone</b>
                            <br /><input name="telefone" id="telefone" type="text" style="padding:5px; width:400px;" />
                        </td>
                    </tr>
                    <tr>
                    	<td colspan="3">
                        	<b>Celular</b>
                            <br /><input name="celular" id="celular" type="text" style="padding:5px; width:400px;" />
                        </td>
                    </tr>
                    <tr height="10"></tr>
                    <tr>
                    	<td colspan="3">                    	
                            <input name="confirmarAgenda" type="button" value="Confirmar Agendamento" onclick="checkForm('cad');" style="background:#063; color:#fff; font-weight:bold; border:none; padding:7px 10px; outline:none; cursor:pointer;"/>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
	</form>
</body>
</html>